package lpl.com.xyd.test.manage.factory;

import com.alibaba.fastjson.JSONArray;
import lpl.com.xyd.test.manage.common.factory.AbstractDomainFactory;
import lpl.com.xyd.test.manage.common.factory.AutowiredDomainFactory;
import lpl.com.xyd.test.manage.common.utils.CollectionUtils;
import lpl.com.xyd.test.manage.domain.MenuDomain;
import lpl.com.xyd.test.manage.dao.MenuMapperDAO;
import lpl.com.xyd.test.manage.dto.MenuDTO;
import lpl.com.xyd.test.manage.param.MenuQueryParamDTO;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.List;

/**
 * @Author mingliang
 * @Date 2018-02-05 10:28
 */
@Component
public class MenuDomainFactory extends AbstractDomainFactory<MenuDomain, MenuQueryParamDTO> {

    private static final Logger LOGGER = LoggerFactory.getLogger(MenuDomainFactory.class);

    @Autowired
    private AutowiredDomainFactory autowiredDomainFactory;

    @Autowired
    private MenuMapperDAO menuMapperDAO;

    @Override
    public MenuDomain create(MenuQueryParamDTO paramDTO) {
        return autowiredDomainFactory.create(MenuDomain.class);
    }

    @Override
    public MenuDomain active(String domainId) {
        return null;
    }

    @Override
    public List<MenuDomain> activeList(MenuQueryParamDTO param) {
        LOGGER.info("激活领域");
        List<MenuDTO> menuDTOList = menuMapperDAO.selectAll();
        List<MenuDomain> menuDomains = new ArrayList<>(menuDTOList.size());
        CollectionUtils.copy(menuDTOList,menuDomains,MenuDomain.class);
        LOGGER.info("domain：{}",JSONArray.toJSONString(menuDomains));
        return menuDomains;
    }

    @Override
    public Boolean store(MenuDomain domain) {
        return null;
    }

    @Override
    public Boolean reStore(MenuDomain domain) {
        return null;
    }

    @Override
    public Boolean reStore(List<MenuDomain> domains) {
        return null;
    }

    @Override
    public boolean delete(Long domainId) {
        return false;
    }

    @Override
    public boolean delete(List<Long> domainId) {
        return false;
    }
}
